﻿<navigation:Page 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
        xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
        xmlns:helpers="clr-namespace:InsuranceAdjuster.Helpers"
        xmlns:System="clr-namespace:System;assembly=mscorlib" 
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
        x:Class="InsuranceAdjuster.Views.SyncSettingsView"
        mc:Ignorable="d"
        d:DesignWidth="640" d:DesignHeight="300"
        Width="1000" Height="660" 
        Title="SyncStatusView Page"
        HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    <navigation:Page.Resources>


    	<Style TargetType="TextBox">
    		<Setter Property="FontFamily" Value="Segoe"/>
    		<Setter Property="VerticalAlignment" Value="Center"/>
    		<Setter Property="FontSize" Value="18"/>
    	</Style>
    	<Style TargetType="HyperlinkButton">
    		<Setter Property="FontSize" Value="16" />
    		<Setter Property="Foreground" Value="#FFFFFFFF" />
    		<Setter Property="FontWeight" Value="Normal" />
    		<Setter Property="Margin" Value="8 8 8 0" />
    		<Setter Property="Padding" Value="6" />
    		<Setter Property="Background" Value="#FF807B6E" />
    	</Style>
    	<helpers:VisibilityConverter x:Key="VisibilityConverter" />
    	<helpers:NotVisibilityConverter x:Key="NotVisibilityConverter" />

    </navigation:Page.Resources>
	<navigation:Page.DataContext>
		<Binding Path="SyncSettings" Source="{StaticResource Locator}"/>
	</navigation:Page.DataContext>
	<Grid x:Name="LayoutRoot">
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="IsOnline">
				<VisualState x:Name="Online">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ContentControl.Content)" Storyboard.TargetName="hyperlinkButton">
							<DiscreteObjectKeyFrame KeyTime="0" Value="Go Offline"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Offline">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="syncNowHyperlinkButton">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<System:Boolean>False</System:Boolean>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ContentControl.Content)" Storyboard.TargetName="hyperlinkButton">
							<DiscreteObjectKeyFrame KeyTime="0" Value="Go Online"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
		<Grid.RowDefinitions>
			<RowDefinition Height="{StaticResource TitleBarHeight}"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto"  />
			<ColumnDefinition Width="*" />
			<ColumnDefinition Width="Auto"  />
		</Grid.ColumnDefinitions>
		
		<i:Interaction.Behaviors>
        <ei:DataStateBehavior Binding="{Binding Path=EntityManager.WorkOffline, Mode=TwoWay}"
                                       Value="True"
                                       TrueState="Offline"
                                       FalseState="Online">
        </ei:DataStateBehavior>
		</i:Interaction.Behaviors>
		
		<Border Grid.Row="1" Grid.RowSpan="99" Grid.ColumnSpan="99" Margin="0" Padding="0">
			<Rectangle Style="{StaticResource YellowRectangleStyle}"/>
		</Border>
		
		<TextBlock  Grid.Row="0"  Grid.ColumnSpan="99" Margin="0,31,0,0"  HorizontalAlignment="Left" TextWrapping="Wrap" Text="Sync Settings" Style="{StaticResource TitleStyle}" FontFamily="Arial" d:LayoutOverrides="Height"/>
		
		
		<sdk:Label Content="Activity Sync Interval" Margin="4" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2"/>
		<StackPanel Orientation="Horizontal" Margin="4" Grid.Row="2" Grid.Column="1">
			<TextBox Width="100" 
				Text="{Binding ActivitySyncInterval, Mode=TwoWay}" 
				Foreground="{StaticResource MainTextColor}" />
			<sdk:Label Content="seconds" Margin="4 0 0 0" />
		</StackPanel> 
		<sdk:Label Content="Reference Sync Interval" Margin="4" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="3"/>
		<StackPanel Orientation="Horizontal" Margin="4" Grid.Row="3" Grid.Column="1">
			<TextBox Width="100" 
				Text="{Binding ReferenceSyncInterval, Mode=TwoWay}" 
				Foreground="{StaticResource MainTextColor}" />
			<sdk:Label Content="seconds" Margin="4 0 0 0" />
		</StackPanel>   	
		
		<StackPanel Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="99" Orientation="Horizontal">
			<HyperlinkButton x:Name="hyperlinkButton" Content="Go Online" Command="{Binding ChangeNetworkStatusCommand}" Margin="8 8 0 8"/>
			<HyperlinkButton x:Name="syncNowHyperlinkButton" Content="Sync Now" Command="{Binding SyncNowCommand}"  Margin="8 8 0 8" />
            <HyperlinkButton Content="View Anchors" Command="{Binding ShowAnchorsDialogCommand}" Margin="8 8 0 8" />
            <HyperlinkButton Content="Purge Cache" Command="{Binding PurgeCacheCommand}" Margin="8 8 0 8" />
        </StackPanel>
	</Grid>
</navigation:Page>
